﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DoAn
{
    public class GoldBuilding : Building
    {
        public GoldBuilding(ContentManager content, string pic, int npic, Vector2 topleft, Vector2 size, int delay, int maxblood, int armor, int damage, int flag, int numstate)
        {
            Init(content, pic, npic, ref topleft, ref size, ref delay, ref maxblood, ref armor, ref damage, flag, numstate, 7);
        }

        override public void newBuilding(Vector2 pos, Object init)
        {
            //Position = Game1.center(pos) - new Vector2(Game1.CellWidth / 2, Game1.CellHeight / 2);
            CheckCell(ref pos);
            MySprite temp = new MySprite(SpriteModel);
            //temp.Blood = Maxblood;
            temp.Position = Game1.center(pos) - new Vector2(Game1.CellWidth / 2, Game1.CellHeight / 2);
            mySprites.Add(temp);
            nSprites++;
            init.mySprites.Add(temp);
            init.nSprites++;
        }
        
        static public void CheckCell(ref Vector2 pos)
        {
            Vector2 v = Game1.LocalCell(pos);
            int x, y;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    x = (int)v.X + j;
                    y = (int)v.Y + i;
                    if (x >= 0 && x < Game1.nCols && y >= 0 && y < Game1.nRows)
                        Game1.b[y, x] = true;
                }
            }
        }
        static public void UnCheckCell(ref Vector2 pos)
        {
            Vector2 v = Game1.LocalCell(pos);
            int x, y;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    x = (int)v.X + j;
                    y = (int)v.Y + i;
                    if (x >= 0 && x < Game1.nCols && y >= 0 && y < Game1.nRows)
                        Game1.b[y, x] = false;
                }
            }
        }
    }
}
